package com.happy.xiao.common.rabbitmq.db.service.impl;


import com.happy.xiao.common.rabbitmq.db.entity.MessageLog;
import com.happy.xiao.common.rabbitmq.db.repository.MessageLogRepository;
import com.happy.xiao.common.rabbitmq.db.service.IMessageLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class MessageLogServiceImpl implements IMessageLogService {

    @Autowired
    MessageLogRepository messageLogRepository;

    @Override
    public MessageLog add(MessageLog obj) {

        if (obj == null) return null;

        try {
            return messageLogRepository.save(obj);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public MessageLog findByMessageId(String messageId) {

        if (StringUtils.isEmpty(messageId)) return null;
        try {
            return messageLogRepository.findByMessageId(messageId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
